package net.zjitc.dao.impl;

import net.zjitc.dao.UserDao;
import net.zjitc.pojo.User;
import net.zjitc.service.UserService;
import net.zjitc.utils.db.C3P0Utils;
import org.apache.commons.dbutils.QueryRunner;
import org.apache.commons.dbutils.handlers.BeanListHandler;

import java.sql.SQLException;
import java.util.List;

/**
 * Created by Administrator on 2017/11/9.
 */
public class UserDaoImpl implements UserDao{
    public List<User> findAll()  {
        QueryRunner runner = new QueryRunner(C3P0Utils.getDataSource());
        String sql = "select * from user";
        try {
            List<User> list = (List<User>) runner.query(sql,new BeanListHandler(User.class));
            return list;
        } catch (SQLException e) {
            e.printStackTrace();
        }
        return null;
    }
}
